/*
 *  $Id: DrakeRider.cs 1051 2010-05-18 22:10:41Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima.Cards001.Air.Creatures {
    public class DrakeRider: CreatureCard {
        public DrakeRider(): base("001_a_c_drake_rider") {
            Level = CompleteLevel.ReadyForTest;
            Element = ElementType.Air;
            Value = 100;
            SetRace<Races.Dragon>();
            Damage = 4;
            Health = 3;
			AddManaCost(ElementType.Air, 4);
        }
        public override void SetNaturalAffects(ICollector<Affect> affects) {
            affects.Add<Affects.Flight>();
            affects.Add<DrakeRiderBerserk>();
        }

        private class DrakeRiderBerserk: GameObjectsConditionalAffect {
            public override string Id {
                get { return AffectManager.GetCardId<DrakeRider>("berserk"); }
            }

            protected override bool IsEnabled() {
                Player player = Owner.Owner;
                return IsEnabled(player) || IsEnabled(player.Enemy);
            }
            private bool IsEnabled(Player player) {
                foreach (Creature cr in player.GetCreatures())
                    if (IsDragon(cr)) return true;
                return false;
            }

            protected override void AddAffects() {
                Add(new Affects.Berserk());
            }

            private static bool IsDragon(Creature cr) {
                return !(cr.Card is DrakeRider) && (cr.Race.IsRace<Races.Dragon>());
            }
        }
    }
}
